home *** CD-ROM | disk | FTP | other *** search
- library PropertySheet;
- {********************************************************************}
- {** Library : PropertySheet **}
- {** **}
- {** Description : This DLL contains a Windows 95 shell extension **}
- {** to display the properties of a designated type of file. **}
- {** **}
- {** This module contains the neccessary entry points for a COM **}
- {** object. CLSID = AA6A37C0-04F9-11D0-8AFB-00C0DF44273D **}
- {** **}
- {** Installation Instructions: **}
- {** **}
- {** Run: REGSVR32 PROPERTYSHEET.DLL to register the server **}
- {** Right click a .??? file and click on the details tab **}
- {** **}
- {** Run: REGSVR32 /u PROPERTYSHEET.DLL to uninstall the server **}
- {** **}
- {** **}
- {** Version History : **}
- {** **}
- {** V1.00 First Release version (source+binary) 04/11/96 **}
- {** **}
- {** Copyright (C) 1996 Warren F. Young **}
- {********************************************************************}
- uses
- SysUtils,
- OLE2,
- ShlObj,
- Registry,
- Windows,
- PageDefn in 'PageDefn.pas',
- Properties in 'Properties.pas',
- resource in 'Resource.pas',
- ClassFactory in 'ClassFactory.pas',
- Global in 'Global.pas';
-
-
- {********************************************************************}
- {** Module Information **}
- {********************************************************************}
- {$D A Property page shell extension. Copyright (c) 1996 Warren F. Young}
-
- {$R Props.res} { resource include }
-
-
- {********************************************************************}
- {** Function : DllCanUnloadNow **}
- {** **}
- {** Description : This returns S_OK if it is safe to unload the **}
- {** library. **}
- {** **}
- {********************************************************************}
- function DllCanUnloadNow:HResult; stdcall;
- begin
- if RefThisDLL=0 then
- Result:=S_OK
- else
- Result:=S_FALSE;
- end;
-
-
- {********************************************************************}
- {** Function : DllGetClassObject **}
- {** **}
- {** Description : This function creates a class factory and **}
- {** returns a pointer to it. **}
- {********************************************************************}
- function DLLGetClassObject(const clsid: TCLSID; const iid: TIID; var pv):HResult; stdcall;
- var
- FClassFactory : TClassFactory;
- hr : hResult;
- begin
- pointer(pv):=nil;
- if not ISEqualCLSID(clsid,CLSID_PropSheet) then
- begin
- Result:=CLASS_E_CLASSNOTAVAILABLE;
- exit;
- end;
-
- FClassFactory:= TClassFactory.Create;
-
- if FClassFactory=nil then
- begin
- Result:=E_OUTOFMEMORY;
- exit;
- end;
-
- hr:=FClassFactory.QueryInterface(iid,pv);
- if FAILED(hr) then
- FClassFactory.Destroy;
-
- Result:=hr;
- end;
-
-
- {********************************************************************}
- {** Function : DllRegisterServer **}
- {** **}
- {** Description : This function tries to register the shell **}
- {** extension into the Paint.Picture's list of shell extensions **}
- {********************************************************************}
- function DllRegisterServer:HResult;
- var
- ModuleFilename : array[0..255] of char;
- Registry : TRegistry;
- KeyName : string;
- begin
- Registry:=TRegistry.Create; {create a registry manipulation object}
-
- GetModuleFilename(hInstance,ModuleFilename,sizeof(ModuleFilename)-1);
- with Registry do
- begin
- RootKey:=HKEY_CLASSES_ROOT;
-
- {** Register the shell extension class **}
- OpenKey('\CLSID\'+StrCLSID_PropSheet,TRUE); { open/create the key }
- WriteString('',StrDescription);
- OpenKey('InprocServer32',TRUE);
- WriteString('',ModuleFilename);
- WriteString('ThreadingModel','Apartment');
-
- {** Register the shell extension part **}
- OpenKey('\.mww',TRUE);
- KeyName := ReadString('');
- if Keyname = '' then
- begin
- WriteString('','MusicWorksFile');
- OpenKey('\.mww',TRUE);
- KeyName := ReadString('');
- end;
- OpenKey('\'+KeyName+'\shellex\PropertySheetHandlers\PropSheet_WFY',TRUE);
- WriteString('',StrCLSID_PropSheet);
- end;
-
- Registry.Destroy;
- Result:=S_OK;
- end;
-
-
- {********************************************************************}
- {** Function : DllUnregisterServer **}
- {** **}
- {** Description : This function tries to unregister the shell **}
- {** extension from the Paint.Picture's list of shell extensions **}
- {********************************************************************}
- function DllUnregisterServer:HResult;
- var
- Registry : TRegistry;
- KeyName : string;
- begin
- Registry:=TRegistry.Create;
-
- with Registry do
- begin
- RootKey:=HKEY_CLASSES_ROOT;
- OpenKey('\CLSID',FALSE); { move to HKEY_CLASSES_ROOT\CLSID }
- DeleteKey(StrCLSID_PropSheet); { remove the shell extension class key }
-
- OpenKey('\.mww',TRUE);
- KeyName := ReadString('');
- OpenKey('\'+KeyName+'\shellex\PropertySheetHandlers\PropSheet_WFY',FALSE);
- DeleteKey('PropSheet_WFY'); { remove the property sheet setting from registry }
- end;
- Registry.Destroy;
- Result:=S_OK;
- end;
-
-
-
- {********************************************************************}
- exports
- DllGetClassObject name 'DllGetClassObject',
- DllCanUnloadNow name 'DllCanUnloadNow',
- DllRegisterServer name 'DllRegisterServer',
- DllUnregisterServer name 'DllUnregisterServer';
-
- begin
- end.
-